package com.coder520.common.utils;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by vern on 2017/9/18.
 */

public class DateUtils {

    private static Calendar calendar=Calendar.getInstance();
    /**
     * 得到今天是周几
     * @return
     */
    public static int getTodayWeek() {
        calendar.setTime(new Date());
        int week=calendar.get(Calendar.DAY_OF_WEEK)-1;
        if(week<0) week=7;
        return week;
    }

    /**
     * 就算时间差 分钟数
     * @param startdate
     * @param enddate
     * @return
     */
    public static int getMunite(Date startdate,Date enddate){
       long start=startdate.getTime();
       long end= enddate.getTime();
       int munite=(int)(end-start)/(1000*60);
        return munite;
    }


    /**
     * 获取当天某个时间
     * @param hour
     * @param munite
     * @return
     */
    public static Date getDate(int hour,int munite){
       calendar.set(Calendar.HOUR_OF_DAY,hour);
       calendar.set(Calendar.MINUTE,munite);
        return calendar.getTime();
    }
}
